package com.sky.context;

public class ThreadLocalContext {

    //创建一个线程的局部变量，用于存储当前线程的上下文信息
    static ThreadLocal<Long> context = new ThreadLocal<Long>();

    public static void setCurrentLocalUserId(Long currentUserId) {
        context.set(currentUserId);//设置当前线程的局部变量,值为当前登入用户的id
    }

    public static Long getCurrentLocalUserId() {
        return context.get(); //获取当前线程的局部变量，值为当前登入用户的id
    }

    public static void clear() {
        context.remove(); //清除当前线程的局部变量
    }
}
